package com.atguigu.srb.sms.utils;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

@Configuration
@Data
@ConfigurationProperties(prefix = "aliyun.sms")
public class SmsProperties implements InitializingBean {
    private String host ;
    private String path ;
    private String method ;
    private String appcode ;
    private String registeTplId ;
    private String authTplId ;

    public static String HOST ;
    public static String PATH ;
    public static String METHOD ;
    public static String APP_CODE ;
    public static String REGISTE_TPLID ;
    public static String AUTH_TPLID ;
    //spring提供的 可以在对象创建后立即调用 对属性值进行初始化 校验的方法
    @Override
    public void afterPropertiesSet() throws Exception {
        HOST = this.host;
        PATH = this.path;
        METHOD = this.method;
        APP_CODE = this.appcode;
        REGISTE_TPLID = this.registeTplId;
        AUTH_TPLID = this.authTplId;
    }

//    @PostConstruct
//    public void init(){
//        HOST = this.host;
//        PATH = this.path;
//        METHOD = this.method;
//        APP_CODE = this.appcode;
//        REGISTE_TPLID = this.registeTplId;
//        AUTH_TPLID = this.authTplId;
//    }
}
